/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package l2bot.network.game.ServerPackets;

import javolution.util.FastList;
//import net.sf.l2j.gameserver.model.L2Character;
//import net.sf.l2j.gameserver.model.L2Object;


/**
 * sample
 * 06 8f19904b 2522d04b 00000000 80 950c0000 4af50000 08f2ffff 0000    - 0 damage (missed 0x80)
 * 06 85071048 bc0e504b 32000000 10 fc41ffff fd240200 a6f5ffff 0100 bc0e504b 33000000 10                                     3....

 * format
 * dddc dddh (ddc)
 *
 * @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/03/27 15:29:39 $
 */
public class Attack extends L2GameServerPacket
{
    private class Hit
    {
    	protected int _targetId;
    	protected int _damage;
    	protected int _flags;

        Hit(int objid, int damage, int flags)
        {
            _targetId = objid;
            _damage = damage;
            /*if (soulshot) _flags |= 0x10 | _grade;
            if (crit)      _flags |= 0x20;
            if (shld)      _flags |= 0x40;
            if (miss)      _flags |= 0x80;*/
            
            _flags = flags;

        }
    }

	// dh

	//private static final String _S__06_ATTACK = "[S] 33 Attack";
	//protected final int _attackerObjId;
	//public final boolean soulshot;
    //protected int _grade;
	//private int _x;
	//private int _y;
	//private int _z;
	//private Hit[] _hits;

	/**
	 * @param attacker the attacker L2Character
	 * @param ss true if useing SoulShots
	 */
	//public Attack()
	//{
		//_attackerObjId = attacker.getObjectId();
		//soulshot = ss;
        //_grade = grade;
		//_x = attacker.getX();
		//_y = attacker.getY();
		//_z = attacker.getZ();
		//_hits = new Hit[0];
	//}
//
	///**
	 //* Add this hit (target, damage, miss, critical, shield) to the Server-Client packet Attack.<BR><BR>
	 //*/
	//public void addHit(L2Object target, int damage, boolean miss, boolean crit, boolean shld)
	//{
		//// Get the last position in the hits table
		//int pos = _hits.length;
//
		//// Create a new Hit object
		//Hit[] tmp = new Hit[pos+1];
//
		//// Add the new Hit object to hits table
		//for (int i=0; i < _hits.length; i++)
			//tmp[i] = _hits[i];
		//tmp[pos] = new Hit(target, damage, miss, crit, shld);
		//_hits = tmp;
	//}

	/**
	 * Return True if the Server-Client packet Attack conatins at least 1 hit.<BR><BR>
	 */
	//public boolean hasHits()
	//{
		//return _hits.length > 0;
	//}

	@Override
        public void readP()
	{
		//writeC(0x33);
                FastList<Hit> hits = new FastList<Hit>();
            
		int objid = readD();//writeD(_attackerObjId);
		int targetId = readD();//writeD(_hits[0]._targetId);
                
                hits.add(new Hit(targetId,readD(),readC()));
                
		//writeD(_hits[0]._damage);
		//writeC(_hits[0]._flags);
                
                int x = readD();
                int y = readD();
                int z = readD();
		//writeD(_x);
		//writeD(_y);
		//writeD(_z);
                
		int s = readH();//writeH(_hits.length-1);
                
                for (int i=0;i<s;i++){
                    hits.add(new Hit(readD(),readD(),readC()));
                }
                 
                
		//for (int i=1; i < _hits.length; i++)
		//{
			//writeD(_hits[i]._targetId);
			//writeD(_hits[i]._damage);
			//writeC(_hits[i]._flags);
		//}
	}

	/* (non-Javadoc)
	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
	 */
	//@Override
	//public String getType()
	//{
		//return _S__06_ATTACK;
	//}
}
